package Vista;
import java.util.*;


import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;

import Controlador.Sistema;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.sql.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class ViewFacturaCliente extends javax.swing.JFrame 
{
	private JLabel jLabel4;
	private JButton jBcancelar;
	private JButton JBFacturar;
	private JTextField jLMesFactura;
	public static ViewFacturaCliente instancia;

	private static final long serialVersionUID = 1L;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				ViewFacturaCliente inst = new ViewFacturaCliente();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
				
			}
		});
	}
	
	private ViewFacturaCliente() {
		super();
		initGUI();
	}
	
	public static ViewFacturaCliente getInstancia() 
	{
		if (instancia== null)
			instancia = new ViewFacturaCliente();
		return instancia;
	}
		
	
	public ViewFacturaCliente(MenuPrincipal mnu) {
		super();
		initGUI();
		mnu.dispose();
	}
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			this.setTitle("Facturacion Mensual");

			{
				jLabel4 = new JLabel();
				getContentPane().add(jLabel4);
				jLabel4.setText("Fecha (\"YYYY-MM-DD\")");
				jLabel4.setBounds(12, 13, 141, 18);
			}
			{
				jLMesFactura = new JTextField();
				getContentPane().add(jLMesFactura);
				jLMesFactura.setBounds(200, 12, 107, 21);
			}
			{
				JBFacturar = new JButton();
				getContentPane().add(JBFacturar);
				JBFacturar.setText("Facturar");
				JBFacturar.setBounds(0, 45, 105, 21);
				JBFacturar.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) 
					{
  				SimpleDateFormat fdt = new SimpleDateFormat("yyyy-MM-dd");
						String sFecha = jLMesFactura.getText();
						java.util.Date fec = null;
						try{
							fec = fdt.parse(sFecha);
						}catch (ParseException ex){
							ex.printStackTrace();
						}
						
						Sistema.getInstancia().FacturarMes(fec);
						
						
						
					}
				});
			}
			{
				jBcancelar = new JButton();
				getContentPane().add(jBcancelar);
				jBcancelar.setText("Cancelar");
				jBcancelar.setBounds(193, 45, 114, 21);
				jBcancelar.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt)
					{
						jBcancelarActionPerformed();
					}
				});
			}
			pack();
			this.setSize(352, 130);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
		private void jBcancelarActionPerformed()
		{
			
		}

}
